{% load event_tags %}
{{form.non_field_errors}}
{% for field in form.hidden_fields %}
    {{ field }}
{% endfor %}

{% for field in form.visible_fields %}
    <div class="form-group {% if field.errors %}has-error{% endif %}">
        {% if field|is_checkbox %}

                <div class="checkbox">
                    {% if field.auto_id %}
                        <label {% if field.field.required and form.required_css_class %}class="control-label"{% endif %}>
                            {{ field }} <span>{{ field.label }}</span>
                        </label>
                    {% endif %}
                    {% for error in field.errors %}
                        <span class="help-block {{ form.error_css_class }}">{{ error }}</span>
                    {% endfor %}
    
                    {% if field.help_text %}
                        <p class="help-block">
                            {{ field.help_text|safe }}
                        </p>
                    {% endif %}
                </div>
        {% elif field|is_radio %}
        <!-- Only used for the multiple choice questions !-->
            {% if field.auto_id %}
                <label class="control-label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">{{ field.label }}</label>
            {% endif %}

                {% for choice in field %}
                    <div class="radio">
                        <label>
                            {{ choice.tag }}
                            {{ choice.choice_label }}
                        </label>
                    </div>
                {% endfor %}
    
                {% for error in field.errors %}
                    <span class="help-block {{ form.error_css_class }}">{{ error }}</span>
                {% endfor %}
    
                {% if field.help_text %}
                <p class="help-block">
                    {{ field.help_text|safe }}
                </p>
                {% endif %}
        {% elif field|is_multiple_checkbox %}
        <!-- Only used for the multiple choice questions (multi select) !-->
            {% if field.auto_id %}
                <label class="control-label {% if field.field.required %}{{ form.required_css_class }}{% endif %}">{{ field.label }}</label>
            {% endif %}

                {% for choice in field %}
                    <div class="checkbox {{ classes.value }} multiple-checkbox">
                        <label>
                            {{ choice.tag }}
                            {{ choice.choice_label }}
                        </label>
                    </div>
                {% endfor %}
    
                {% for error in field.errors %}
                    <span class="help-block {{ form.error_css_class }}">{{ error }}</span>
                {% endfor %}
    
                {% if field.help_text %}
                <p class="help-block">
                    {{ field.help_text|safe }}
                </p>
                {% endif %}
        {% else %}
            {% if field.auto_id %}
                <label class="control-label {% if field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>
            {% endif %}
    
            <div class="checkbox {{ classes.value }} {% if field|is_multiple_checkbox %}multiple-checkbox{% endif %}">
                {{ field|addcss:"class:form-control" }}
    
                {% for error in field.errors %}
                    <span class="help-block {{ form.error_css_class }}">{{ error }}</span>
                    {% endfor %}
    
                {% if field.help_text %}
                    <p class="help-block">
                        {{ field.help_text|safe }}
                    </p>
                {% endif %}
            </div>
        {% endif %}
    </div>
{% endfor %}